]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionSystem: Add support for mode-specific extensions
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 29 Nov 2012 15:09:21 +0000 (16:09 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 5 Dec 2012 20:56:57 +0000 (21:56 +0100)
As currently envisioned, the fallback replacement in 3.8 should be
a separate session at the login screen. As we will use extensions
to implement this mode, we need a way to specify extensions per
session rather than per user, so add a session-mode property for
extensions that should be loaded in addition to the user-defined
ones.

https://bugzilla.gnome.org/show_bug.cgi?id=689305

js/ui/extensionSystem.js
js/ui/sessionMode.js

index 62775a3b73ca94a4210d40144558bac33c5e04ca..7ec96bc4d89b35f51c5ac95210692c7a48d90d56 100644 (file)
@@ -211,8 +211,16 @@ function initExtension(uuid) {
     _signals.emit('extension-loaded', uuid);
 }
 
+function getEnabledExtensions() {
+    let extensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
+    if (!Array.isArray(Main.sessionMode.enabledExtensions))
+        return extensions;
+
+    return Main.sessionMode.enabledExtensions.concat(extensions);
+}
+
 function onEnabledExtensionsChanged() {
-    let newEnabledExtensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
+    let newEnabledExtensions = getEnabledExtensions();
 
     if (!enabled)
         return;
@@ -246,7 +254,7 @@ function onEnabledExtensionsChanged() {
 
 function _loadExtensions() {
     global.settings.connect('changed::' + ENABLED_EXTENSIONS_KEY, onEnabledExtensionsChanged);
-    enabledExtensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
+    enabledExtensions = getEnabledExtensions();
 
     let finder = new ExtensionUtils.ExtensionFinder();
     finder.connect('extension-found', function(signals, extension) {
@@ -288,10 +296,17 @@ function disableAllExtensions() {
 }
 
 function _sessionUpdated() {
-    if (Main.sessionMode.allowExtensions)
+    // For now sessionMode.allowExtensions controls extensions from both the
+    // 'enabled-extensions' preference and the sessionMode.enabledExtensions
+    // property; it might make sense to make enabledExtensions independent
+    // from allowExtensions in the future
+    if (Main.sessionMode.allowExtensions) {
+        if (initted)
+            onEnabledExtensionsChanged();
         enableAllExtensions();
-    else
+    } else {
         disableAllExtensions();
+    }
 }
 
 function init() {
index eacefd094c1fbc84c97f658097066ba408a6870d..25a5efa95e5190a29b57978195ad93929169a1f6 100644 (file)
@@ -18,6 +18,7 @@ const _modes = {
         showCalendarEvents: false,
         allowSettings: false,
         allowExtensions: false,
+        enabledExtensions: [],
         hasRunDialog: false,
         hasWorkspaces: false,
         hasWindows: false,